<template>
	<view class="messageList">
		<view class="inform-content">
			<view class="inform-border" v-for="(informborder, index) in informBorder" @click="informchange(informborder.url)">
				<view class="infom-one">
					<view class="inform-content-text">
						<view class="inform-content-title">
							{{ informborder.title }}
						</view>
						<view class="inform-words">
							{{ informborder.description }}
						</view>
					</view>
					<view class="inform-time">
						{{ formatDate(informborder.ctime) }}
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import request from '@/api/request.js';
export default {
	data() {
		return {
			informBorder : {}
		};
	},
	onLoad() {
		this.getInfo();
	},
	methods: {
		informchange(url) {
			let informurl = url;
			uni.navigateTo({
				url: `/pages/information/information?url=${informurl}`
			});
		},
		async getInfo() {
			let data = await request.get('/api/index/getinformation');
			if (data.code === 1) this.informBorder = data.data;
		},
		formatDate(value) {
			var time = new Date(value);
			var year = time.getFullYear(); // 年
			var month = time.getMonth() + 1 < 10 ? '0' + (time.getMonth() + 1) : time.getMonth() + 1; // 月
			var day = time.getDate() < 10 ? '0' + time.getDate() : time.getDate(); // 日
			var hours = time.getHours() < 10 ? '0' + time.getHours() : time.getHours(); // 时
			var minutes = time.getMinutes() < 10 ? '0' + time.getMinutes() : time.getMinutes(); // 分
			var seconds = time.getSeconds() < 10 ? '0' + time.getSeconds() : time.getSeconds(); // 秒
			return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
		}
	}
};
</script>

<style scoped lang="scss">
.messageList {
	.inform-content {
		background-color: #ffffff;
		.inform-border {
			border-bottom: 1px solid #ddd;
			.infom-one {
				padding-left: 0.75rem;
				.inform-content-text {
					padding-top: 0.5rem;
					padding-bottom: 0.5rem;
					.inform-content-title {
						line-height: 1.5rem;
						max-width: 100%;
					}
					.inform-words {
						font-size: 0.9rem;
						color: #757575;
						display: -webkit-box;
						overflow: hidden;
						text-overflow: ellipsis;
						word-wrap: break-word;
						word-break: break-all;
						white-space: normal !important;
						-webkit-line-clamp: 2;
						-webkit-box-orient: vertical;
					}
				}
				.inform-time {
					font-size: 0.9rem;
					padding: 0.5rem 0;
					color: #757575;
				}
			}
		}
		
	}
}
</style>
